package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.member.dos.MemberWalletDO;
import com.enation.app.javashop.model.member.vo.MemberDepositeVO;
import com.enation.app.javashop.service.member.DepositeManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @description: 预存款客户端实现
 * @author: liuyulei
 * @create: 2019-12-30 18:41
 * @version:1.0
 * @since:7.1.4
 **/
@Api(description = "会员收藏商品api")
@RestController
@RequestMapping("/client/members")
@Validated
@ApiIgnore
public class DepositeClientController {

    @Autowired
    private DepositeManager depositeManager;

    @RequestMapping(value = "/{member_id}/deposite/increase", method = RequestMethod.POST)
    public Boolean increase(@RequestParam("money") Double money, @PathVariable("member_id")Long memberId, @RequestParam("detail") String detail) {
        return this.depositeManager.increase(money,memberId,detail);
    }

    @RequestMapping(value = "/{member_id}/deposite/reduce", method = RequestMethod.POST)
    public Boolean reduce(@RequestParam("money") Double money, @PathVariable("member_id")Long memberId, @RequestParam("detail") String detail) {
        return this.depositeManager.reduce(money,memberId,detail);
    }

    @RequestMapping(value = "/{member_id}/member-wallet", method = RequestMethod.GET)
    public MemberWalletDO getModel(@PathVariable("member_id")Long memberId) {
        return this.depositeManager.getModel(memberId);
    }

    @RequestMapping(value = "/member-wallet", method = RequestMethod.POST)
    public MemberWalletDO add(@RequestBody MemberWalletDO walletDO) {
        return this.depositeManager.add(walletDO);
    }

    @RequestMapping(value = "/{member_id}/member-wallet/check-pwd", method = RequestMethod.GET)
    public void checkPwd(@PathVariable("member_id")Long memberId, @RequestParam("password")String password) {
        this.depositeManager.checkPwd(memberId,password);
    }

    @RequestMapping(value = "/{member_id}/deposite", method = RequestMethod.GET)
    public MemberDepositeVO getDepositeVO(@PathVariable("member_id")Long memberId) {
        return this.depositeManager.getDepositeVO(memberId);
    }
}
